$(document).ready(function () {


$('#contact_form').validate({
		
	submitHandler: function() {
		
		$('#contact_form').ajaxSubmit({
			beforeSubmit: function() {
				// loading image
				$('#contact_send').attr('disabled', true);
				$('#contact_message').html('<div><img src="../../images/icons/ajax-loader.gif" alt="Chargement ..." /></div>');
				$('#contact_message').show();
			},
			dataType: 'json',
			success: function(e) {
				
				// logged
				if(e.result) {
					$('#contact_form').fadeOut();
					$('#contact_message').html('<div class="success">'+e.message+'</div>');
					$('#contact_message').fadeIn();
					setTimeout("$('#contact_message').fadeOut()", 2000);
					
				// not logged
				} else {
					
					$('#contact_message').html('<div class="error">'+e.message+'</div>');
					$('#contact_message').show();
					$('#contact_send').removeAttr('disabled');
					setTimeout("$('#contact_message').fadeOut()", 2000);
				
				}
			},
			error: function(e) {
				alert(e);
				$('#contact_send').removeAttr('disabled');
			}
			
		});
		
	}
	
});

});
